﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.HeadUpWindow.CUiHeadUpWindow
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.HeadUpWindow;

public abstract class CUiHeadUpWindow : TxWindow
{
  public CUiHeadUpWindow()
  {
    this.ShouldAutoPosition = false;
    this.MaximizeBox = false;
    this.MinimizeBox = false;
  }

  public void Show(System.Drawing.Point topLeft)
  {
    this.Relocate(topLeft);
    ((Window) this).Show();
  }

  public void Relocate(System.Drawing.Point topLeft)
  {
    this.AdjustPositionToWindowBounds(ref topLeft);
    ((Window) this).Left = (double) topLeft.X;
    ((Window) this).Top = (double) topLeft.Y;
  }

  private void AdjustPositionToWindowBounds(ref System.Drawing.Point topLeft)
  {
    Rectangle workingArea = Screen.FromPoint(topLeft).WorkingArea;
    System.Drawing.Point bottomRight = new System.Drawing.Point();
    topLeft.X = (int) ((double) topLeft.X / TxScaling.GetDPIScale());
    topLeft.Y = (int) ((double) topLeft.Y / TxScaling.GetDPIScale());
    workingArea.X = (int) ((double) workingArea.X / TxScaling.GetDPIScale());
    workingArea.Y = (int) ((double) workingArea.Y / TxScaling.GetDPIScale());
    workingArea.Width = (int) ((double) workingArea.Width / TxScaling.GetDPIScale());
    workingArea.Height = (int) ((double) workingArea.Height / TxScaling.GetDPIScale());
    this.getMaxZeroSize(ref bottomRight);
    topLeft.Offset(20, 20);
    int num = topLeft.Y + bottomRight.Y + 3;
    if (num > workingArea.Bottom)
    {
      topLeft.Y -= num - workingArea.Bottom;
      if (topLeft.Y < workingArea.Top)
        topLeft.Y = workingArea.Top + 3;
    }
    if (topLeft.X + bottomRight.X + 3 <= workingArea.Right)
      return;
    topLeft.X -= bottomRight.X + 43;
    if (topLeft.X >= workingArea.Left)
      return;
    topLeft.X = workingArea.Left + 3;
  }

  public abstract void SetObject(ITxObject obj);

  public abstract void getMaxZeroSize(ref System.Drawing.Point bottomRight);
}
